package edu.jd.common;

public class Result {

    private int code;
    private boolean isSuccess;
    private String message;
    private Object data;
    public static final int ERR_CODE_BUSSINESS = 500;
    public static final int ERR_CODE_SYS = 530;

    public static Result success(){
        return new Result(200, true, null, null);
    }
    public static Result success(String message){
        return new Result(200, true, message, null);
    }
    public static Result success(String message, Object data){
        return new Result(200, true, message, data);
    }
    public static Result success(Object data){
        return new Result(200, true, null, data);
    }
    public static Result fail(int code, String message){ return new Result(code, false, message, null); }

    public int getCode() {
        return code;
    }

    public boolean isSuccess() {
        return isSuccess;
    }

    public String getMessage() {
        return message;
    }

    public Object getData() {
        return data;
    }

    public Result(int code, boolean isSuccess, String message, Object data) {
        this.code = code;
        this.isSuccess = isSuccess;
        this.message = message;
        this.data = data;
    }
}
